import 'package:eh_mobile/pages/main/homepage/model/home_device_model.dart';

class DeviceDynamicModel {
  String? type;
  bool? success;
  List<DeviceDynamicModelData>? data;
  String? index;

  DeviceDynamicModel({this.type, this.success, this.data, this.index});

  DeviceDynamicModel.fromJson(Map json) {
    type = json['type'];
    success = json['success'];
    if (json['data'] != null) {
      data = <DeviceDynamicModelData>[];
      json['data'].forEach((v) {
        data!.add(DeviceDynamicModelData.fromJson(v));
      });
    }
    index = json['index'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data['type'] = this.type;
    data['success'] = this.success;
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    data['index'] = this.index;
    return data;
  }
}

class DeviceDynamicModelCmd {
  String? type;
  DeviceDynamicModelData? data;

  DeviceDynamicModelCmd({this.type, this.data});

  DeviceDynamicModelCmd.fromJson(Map json) {
    type = json['type'];
    if (json['data'] != null) {
      data = DeviceDynamicModelData.fromJson(json['data']);
    }
  }
}

class DeviceDynamicModelData {
  List<HomeDeviceModelDevices>? devices;
  String? type;
  int? appear;

  DeviceDynamicModelData({this.devices, this.type, this.appear});

  DeviceDynamicModelData.fromJson(Map<String, dynamic> json) {
    if (json['devices'] != null) {
      devices = <HomeDeviceModelDevices>[];
      json['devices'].forEach((v) {
        devices!.add(new HomeDeviceModelDevices.fromJson(v));
      });
    }else{
      devices = <HomeDeviceModelDevices>[];
    }
    type = json['type'];
    appear = json['appear'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.devices != null) {
      data['devices'] = this.devices!.map((v) => v.toJson()).toList();
    }
    data['type'] = this.type;
    data['appear'] = this.appear;
    return data;
  }
}
